package com.sqx.modules.search.controller.app;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sqx.common.utils.Result;
import com.sqx.modules.app.annotation.Login;
import com.sqx.modules.app.entity.App;
import com.sqx.modules.search.entity.Search;
import com.sqx.modules.search.service.AppSearchService;
import com.sqx.modules.search.service.SearchService;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

/**
 * 搜索记录
 *
 * @author liyuan
 * @since 2021-07-17
 */
@RestController
@RequestMapping("app/Search")
@AllArgsConstructor
@Slf4j
public class AppSearchController {

    private AppSearchService appSearchService;

    /**
     * 查询搜索记录
     */
    @RequestMapping(value = "/selectUserSearchList", method = RequestMethod.GET)
    public Result selectUserSearchList(@ApiParam("用户id") Long userId,
                                       @ApiParam("页码") Integer page,
                                       @ApiParam("条数") Integer limit,
                                       @ApiParam("1服务 2店铺") Integer type) {
        return Result.success().put("data", appSearchService.selectUserSearchList(userId, page, limit,type));
    }

    /**
     * 删除用户的搜索记录
     */
    @Login
    @RequestMapping(value = "/deleteAppSearch", method = RequestMethod.GET)
    public Result deleteAppSearch(@ApiParam("用户id")@RequestAttribute Long userId,
                                  @ApiParam("1服务 2店铺")Integer type){
        return appSearchService.deleteAppSearch(userId,type);
    }
}
